package com.palfund.handler;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

public class MainActivity extends AppCompatActivity {
    private Handler mHandler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i("MainActivity", "---onCreate()--->System.currentTimeMillis()   " + System.currentTimeMillis());
        //运行时间
        long uptimeMillis = SystemClock.uptimeMillis();
        Log.i("MainActivity", "---onCreate()--->uptimeMillis   " + uptimeMillis);
    }

    public void sendMessage(View view) {
        Message message = mHandler.obtainMessage();
        message.what = 0;
        message.obj = "we will go";
        message.sendToTarget();
    }

    class LooperThread extends Thread {

        @Override
        public void run() {
            Looper.prepare();
            mHandler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    super.handleMessage(msg);
                    if (msg.what == 0) {
                        Log.i("MainActivity", "---handleMessage()--->" + msg.obj);
                    }
                }
            };
            Looper.loop();
        }
    }
}
